package com.uzai.console.web.mini;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.mini.miniaddress.*;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.mini.MiniAddressService;
import com.uzai.console.vo.mini.miniaddress.MiniAddressVo;
import com.uzai.console.vo.mini.miniaddress.MiniAreaVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 小程序地址管理管理
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "地址管理",tags = "微信小程序|地址管理")
@ApiSort(7)
@RestController
public class MiniAddressController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(MiniAddressController.class);

    @Autowired
    private MiniAddressService miniAddressService;

    @ApiOperation(value = "分页查询小程序地址管理列表", notes = "分页查询小程序地址管理列表", response = MiniAddressVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/miniAddress/findByPage")
    public Object fingMiniAddressByPage(@RequestBody MiniAddressQuery miniAddressQuery){
        miniAddressQuery.setType(1); //默认查询运营商地址
        return miniAddressService.findMiniAddressByPage(miniAddressQuery);
    }

    @ApiOperation(value = "查询小程序地址管理详情", notes = "查询小程序地址管理详情", response = MiniAddressVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/miniAddress/findById")
    public Object fingMiniAddressById(@RequestBody MiniAddressIdDto miniAddressIdDto){
        return miniAddressService.findMiniAddressById(miniAddressIdDto);
    }

    @SystemLogType(model = SystemModelEnum.MiniAddress, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加小程序地址管理", notes = "添加小程序地址管理")
    @ApiOperationSupport(order = 3)
    @PostMapping("/miniAddress/add")
    public Object addMiniAddress(@RequestBody MiniAddressDto miniAddressDto){
        miniAddressService.addMiniAddress(miniAddressDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.MiniAddress, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改小程序地址管理信息", notes = "修改小程序地址管理信息")
    @ApiOperationSupport(order = 4)
    @PostMapping("/miniAddress/update")
    public Object updateMiniAddress(@RequestBody MiniAddressDto miniAddressDto){
        miniAddressService.updateMiniAddress(miniAddressDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.MiniAddress, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除小程序地址管理信息", notes = "删除小程序地址管理信息")
    @ApiOperationSupport(order = 4)
    @PostMapping("/miniAddress/delete")
    public Object deleteMiniAddress(@RequestBody MiniAddressIdDto miniAddressIdDto){
        miniAddressService.deleteMiniAddress(miniAddressIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.MiniAddress, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "查询地址管理编码列表", notes = "查询地址管理编码列表", response = MiniAreaVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/miniAddress/fingAreaListByParent")
    public Object fingAreaListByParent(@RequestBody MiniAreaByParentDto miniAreaByParentDto){
        return miniAddressService.fingAreaListByParent(miniAreaByParentDto);
    }

}
